package jdbmaplite.util;

public class ArrayUtils {

	/**
	 * Unshift
	 * 
	 * @param array
	 *            T[]
	 * @param additionalArgs
	 *            T...
	 * @return T[]
	 */
	@SuppressWarnings("unchecked")
	public static <T> T[] unshift(T[] array, T... additionalArgs) {
		int additionalArgSize = additionalArgs.length;
		if (additionalArgSize <= 0) {
			return array;
		}
		int originalArraySize = array.length;
		// move connection args into the first position of parameters
		Object[] newParameters = new Object[originalArraySize
				+ additionalArgSize];
		// copy additionalArgs
		System.arraycopy(additionalArgs, 0, newParameters, 0, additionalArgSize);
		// copy original arrays
		System.arraycopy(array, 0, newParameters, additionalArgSize,
				originalArraySize);
		return (T[]) newParameters;
	}

}